<script type="text/javascript">

	$(document).ready(function(){
		$("input[name=room_reserve]").eq(0).attr("checked", true);
		$("input[type=submit]").button();

		//set confirmation dialog
		$( "#form_submit" ).click(function(){
			var room = $("input[name=room_reserve]:checked").val();
			$("#detail_room").html(room);
			$( "#dialog:ui-dialog" ).dialog( "destroy" );
			$( "#dialog-confirm" ).dialog({
				resizable: false,
				height:300,
				modal: true,
				buttons: {
					"ยืนยัน": function() {
						$( "#reserve_form" ).submit();
						$( this ).dialog( "close" );
					},
					"ยกเลิก": function() {
						$( this ).dialog( "close" );
					}
				}
			});
			return false;
		});

		//hide confirmation div
		$( "#dialog-confirm" ).hide();
		
		
	});

</script>

<!-- Confirmation Dialog -->
<div id="dialog-confirm" title="ยืนยันการจอง?">
	<p>ชื่อผู้จอง&nbsp;<span><?php echo $this->session->userdata('name') ."&nbsp;" .$this->session->userdata('surname'); ?></span></p>
	<p>จองห้อง&nbsp;<span id="detail_room"></span></p>
	<p>วันที่ต้องการใช้ห้อง&nbsp;<span><?=$date?></span></p>
	<p>เวลาที่ต้องการใช้ห้อง&nbsp;<span><?=$time_start?>&nbsp;-&nbsp;<?=$time_end?>&nbsp;น.</span></p>
</div>
<!-- end dialog -->

<span>ผลการค้นหา</span>

<?php 

if(isset($output))
{
	?>
	<form id="reserve_form" method="post" action="<?php echo base_url(); ?>main/reserve_meeting">
		<table border="0" class ="datatable">
			<tr>
				<th>&nbsp;</th>
				<th>ห้อง</th>
				<th>จำนวนคนที่รับได้สูงสุด</th>
				<th>ฮาร์ดแวร์ที่มีทั้งหมด</th>
			</tr>
			
			<?php 
			foreach ($output as $row) {
				$hw = str_replace(",", "<br/>", $row['hw']);
				?>
				<tr>
					<td><input type="radio" name="room_reserve" value="<?=$row['roomname']?>" /></td>
					<td><?=$row['roomname']?></td>
					<td><?=$row['roommax']?></td>
					<td><?=$hw?></td>
				</tr>
				<?php 
			}
			?>
			
		</table>
		<input type="hidden" name="usedate" value="<?=$date?>" />
		<input type="hidden" name="time_start" value="<?=$time_start?>" />
		<input type="hidden" name="time_end" value="<?=$time_end?>" />
		<input type="hidden" name="hwuse" value="<?=$hwuse?>" />
		<input type="hidden" name="pcount" value="<?=$peoplecount?>" />
		<br/>
		<input type="submit" id="form_submit" value="จอง" />
	</form>
	<?php
}
else{
	echo "No data matched";
}

?>